﻿<Window x:Class="UBConDemo.Views.UBConShell"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:customControls="clr-namespace:UBConDemo.CustomControls"
        xmlns:viewModels="clr-namespace:UBConDemo.ViewModels"
        xmlns:ubcon="clr-namespace:UBConDemo"
        xmlns:converters="clr-namespace:UBConDemo.Converters"
        
        Title="UBCon Demo" 
        WindowStyle="None" 
        WindowState="Maximized">
    <Window.Resources>
        <viewModels:UBConShellViewModel x:Key="ShellViewModel" />
        <converters:UriToControlConverter x:Key="uriConverter" />
        
    </Window.Resources>
   
    <Grid Background="{DynamicResource  ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcon:ResourceManager}, ResourceId=ShellBackgroundBrush}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <TextBlock Text="{Binding Path=Title, Source={StaticResource ResourceKey=ShellViewModel}, NotifyOnSourceUpdated=True}"
                   FontSize="50"
                   Foreground="White"
                   Margin="30,10"
                   FontWeight="Light"/>
        
        <customControls:UbConItemsControl ItemsSource="{Binding Path=Items, Source={StaticResource ResourceKey=ShellViewModel}, NotifyOnSourceUpdated=True}"
                                          Grid.Row="1"
                                          SelectedItem="{Binding Path=SelectedItem, Source={StaticResource ResourceKey=ShellViewModel}, Mode=TwoWay}"
                                          Margin="30,30"
                                          x:Name="ubconItems"
                                          ContentViewer="{Binding ElementName=_viewPresenterGrid}"
                                          ContentPresenter="{Binding ElementName=_contentPresenter}"/>
        <ScrollBar Orientation="Horizontal" 
                   Grid.Row="2"
                   Minimum="0"
                   Maximum="{Binding Path=ExtentWidth, ElementName=ubconItems, Mode=TwoWay}"
                   ViewportSize="{Binding Path=ViewportWidth, ElementName=ubconItems, Mode=TwoWay}"
                   Value="{Binding Path=HorizontalOffset, ElementName=ubconItems, Mode=TwoWay}">
            <ScrollBar.Style>
                <Style TargetType="{x:Type ScrollBar}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=Visibility, ElementName=_viewPresenterGrid, NotifyOnSourceUpdated=True}" Value="Visible">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ScrollBar.Style>
        </ScrollBar>
        <Grid Grid.Row="1"
              Grid.RowSpan="2"
              Background="{DynamicResource ResourceKey={ComponentResourceKey ResourceId=WhiteBrush, TypeInTargetAssembly={x:Type ubcon:ResourceManager}}}"
              Margin="30, 10"
              x:Name="_viewPresenterGrid"
              Visibility="Collapsed">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Button Height="25"
                    Width="25"
                    Template="{StaticResource ResourceKey=CircularButtonTemplate}"
                    Margin="4"
                    Command="{Binding Path=BackCommand, ElementName=ubconItems}"/>
            <ContentPresenter Content="{Binding Path=SelectedItem, ElementName=ubconItems, NotifyOnSourceUpdated=True, Converter={StaticResource ResourceKey=uriConverter}}" 
                              x:Name="_contentPresenter"
                              Grid.Row="1"
                              Grid.Column="1"/>
        </Grid>
    </Grid>
</Window>
